package com.gregbugaj.nscaffold.util;

public class StringUtil {
	/**
	 * Trim String to given size 
	 * Ex:  trimToSize("Hello Greg", 5, true)=Hello...
	 * Ex:  
	 * @param string
	 * @param size
	 * @param withElipse
	 * @return trim string to size with eclipse or without
	 */
	public static String trimToSize (String string, Integer size, Boolean withElipse) {
		if(string==null) return "";		
		if(size >= string.length()) return string;
		String sub=string.substring(0, size);
		return (withElipse?sub+"...":sub);
	}
	
	/**
	 * Check if the value is Null or empty
	 * @param value to check
	 * @return true if the string is empty or NULL
	 */
	public static boolean isNullOrEmpty(String value){
		return (null == value || value.trim().equals(""));
	}
}
